package edu.sctu.yueding.activitys;

import android.app.Activity;
import android.app.Application;

//import com.tencent.bugly.crashreport.CrashReport;
import com.tencent.bugly.crashreport.CrashReport;
import com.umeng.socialize.PlatformConfig;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import edu.sctu.yueding.utils.httputils.SharePreference;
import io.rong.imkit.RongIM;


/**
 * 应用配置类
 *
 * @author leehongee
 */
public class AppManager extends Application {


    /**
     * 打开的activity
     **/
    private List<Activity> activities = new ArrayList<Activity>();
    /**
     * 应用实例
     **/
    private static AppManager instance;

    private SharePreference sharePreference;

    public static Map<String, Long> map;//用来存放倒计时的时间


    /**
     * 获得实例
     *
     * @return
     */
    public static AppManager getInstance() {
        return instance;
    }

    /**
     * 新建了一个activity
     *
     * @param activity
     */
    public void addActivity(Activity activity) {
        activities.add(activity);
    }

    /**
     * 结束指定的Activity
     *
     * @param activity
     */
    public void finishActivity(Activity activity) {
        if (activity != null) {
            this.activities.remove(activity);
            activity.finish();
            activity = null;
        }
    }

    /**
     * 应用退出，结束所有的activity
     */
    public void exit() {
        for (Activity activity : activities) {
            if (activity != null) {
                activity.finish();
            }
        }
        System.exit(0);
    }

    @Override
    public void onCreate() {
        super.onCreate();
        RongIM.init(this);

        instance = this;
        PlatformConfig.setWeixin("wx16b2c862001960b5", "3323c4364affd21c325b9062308307fb");
        PlatformConfig.setSinaWeibo("3120921808", "12e951821c4d8aef3f5624526e892b42");
        PlatformConfig.setQQZone("1105564855", "AkiHUPvsk4qHcIkF");


        CrashReport.initCrashReport(getApplicationContext(), "efe11f381e", false);

    }








}